const util = require('../../../utils/util.js');
const api = require('../../../config/api.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    value1: 1,
    id: 0,
    notNum: 1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    if (options.id) {
      this.setData({
        id: options.id
      });
    }
    if (options.notNum) {
      this.setData({
        notNum: options.notNum
      });
    }
  },

  handleChange1({
    detail
  }) {
    this.setData({
      value1: detail.value
    })
  },
  toActivate: function() {
    let that = this;
    util.request(api.ActivateCardUrl, {
      id: that.data.id,
      activeNum: that.data.value1
    }).then(function(res) {
      if (res.success) {
        wx.showToast({
          title: res.message
        })
        wx.navigateTo({
         url: '/pages/card/cardInfo/cardInfo?id=' + that.data.id
       })
      }
      wx.showToast({
        title: res.message
      })
    });
  }
})